package cn.wuhan2019mwg.mobile.activity.wuhan2019mwg.adapter;

import android.content.Context;
import android.support.v7.widget.AppCompatTextView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;

;

import java.util.List;


import cn.wuhan2019mwg.mobile.activity.wuhan2019mwg.R;
import cn.wuhan2019mwg.mobile.activity.wuhan2019mwg.utils.Abstract;

/**
 * Created by dell on 2017/7/14.
 */

public class WZAdapter extends BaseAdapter {

    private Context mContext;
    LayoutInflater inflater;
    List<Abstract.Sublist> mlists;


    public WZAdapter(Context context, List<Abstract.Sublist> lists) {
        this.mContext = context;
        inflater = LayoutInflater.from(context);
        mlists = lists;
    }


    @Override
    public int getCount() {
        return mlists == null ? 0 : mlists.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_wz, null);
            viewHolder = new ViewHolder();
            viewHolder.tv1 = (AppCompatTextView) convertView.findViewById(R.id.tv1);
            viewHolder.tv3 = (AppCompatTextView) convertView.findViewById(R.id.tv3);
            viewHolder.tv4 = (AppCompatTextView) convertView.findViewById(R.id.tv4);
            viewHolder.tv8 = (AppCompatTextView) convertView.findViewById(R.id.tv8);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tv4.setText(mlists.get(position).getTitle());
        viewHolder.tv8.setText(mlists.get(position).getDate());
        return convertView;
    }


    public class ViewHolder {
        AppCompatTextView tv1;
        AppCompatTextView tv3;
        AppCompatTextView tv4;
        AppCompatTextView tv8;
    }

}

